//
//  ViewController.m
//  02-UIButton
//
//  Created by dllo on 16/7/16.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    [self creatButton];
    
}

- (void)creatButton
{
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(20, 50, 335, 50);
    button.backgroundColor = [UIColor yellowColor];
    [button setTitle:@"播放" forState:UIControlStateNormal];
    [button addTarget:self action:@selector(playSong:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
}

- (void)playSong:(UIButton *)sender
{
    NSLog(@"播放逻辑");
    [sender removeTarget:self action:@selector(playSong:) forControlEvents:UIControlEventTouchUpInside];
    [sender addTarget:self action:@selector(pauseSong:) forControlEvents:UIControlEventTouchUpInside];
    [sender setTitle:@"暂停" forState:UIControlStateNormal];
}

- (void)pauseSong:(UIButton *)sender
{
    NSLog(@"暂停");
    [sender removeTarget:self action:@selector(pauseSong:) forControlEvents:UIControlEventTouchUpInside];
    [sender addTarget:self action:@selector(playSong:) forControlEvents:UIControlEventTouchUpInside];
    [sender setTitle:@"播放" forState:UIControlStateNormal];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
